home *** CD-ROM | disk | FTP | other *** search
/ Extra! Mainframe / Extra! Mainframe for Windows 95.iso / snaserv / source / snaccah.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-01  |  43.4 KB  |  1,638 lines

  1. /***************************************************************************
  2. **
  3. **      File:                   SNACCAH.C
  4. **      Purpose:                SNA Client for Windows 95 Custom Action
  5. **                              handler for ACME95 setup.
  6. **      Notes:
  7. **
  8. ****************************************************************************/
  9.  
  10. #define SNACCAH_C
  11.  
  12. #include "stdinc.h"
  13. #include <stdlib.h>             /* _MAX_PATH */
  14. #include <dos.h>                /* _dos_getdiskfree() */
  15. #pragma warning (disable : 4001)
  16. #include <lm.h>
  17. #include <winsock.h>
  18. #include <winbase.h>
  19. #include <wsipx.h>
  20. #include <excpt.h>
  21. #include <lmapibuf.h>
  22. #include "service.h"
  23. #include "odbcinst.h"
  24. #pragma warning (default : 4001)
  25. #include "setupapi.h"
  26. #include "cui.h"
  27. #include "stdtypes.h"
  28. #include "setupkit.h"
  29. #include "datadef.h"
  30. #include "parseca.h"
  31. #include "snaccacb.h"
  32. #include "snaccah.h"
  33. #include "resource.h"
  34.  
  35.  
  36. /*
  37.  * WINDOW SYSTEM FILES TO REMOVE DURING UNINSTALL
  38.  *
  39.  *
  40.  */
  41. char WinSysRemovefile[][20] = 
  42.     {
  43.     "APPCST32.DLL",
  44.     "asynctrc.dll",
  45.     "DMODAPPC.dll",
  46.     "LUASTR32.dll",
  47.     "FMISTR32.dll",
  48.     "CSVSTR32.dll",
  49.     "SNACIP.dll",
  50.     "SNACLM.dll",
  51.     "snacnw.dll",
  52.     "SNADMOD.dll",
  53.     "snadump.dll",
  54.     "SNAKRNL.dll",
  55.     "SNANCP.dll",
  56.     "snareg.dll",
  57.     "snatrc.dll",
  58.     "snatrcsn.dll",
  59.     "WAPPC32.dll",
  60.     "WCPIC32.dll",
  61.     "WINAPPC.dll",
  62.     "WINCPIC.dll",
  63.     "WINCSV.dll",
  64.     "WINCSV32.dll",
  65.     "WINMGT32.dll",
  66.     "WINRUI.dll",
  67.     "WINRUI32.dll",
  68.     "WINSLI.dll",
  69.     "WINSLI32.dll",
  70.     ""
  71.     };
  72.  
  73.  
  74.  
  75. /*
  76.  * REGISTRY STRINGS
  77.  *
  78.  *     This table of registry entries is used when creating the registry keys
  79.  *     which are added to the registry during the custom action setup.
  80.  *
  81.  *     DESCRIPTION: The entries of this array consist of:
  82.  *                  Registry Key, Registry Value, Registry Data
  83.  *
  84.  *     The Registry Data is setup during the initialization of this custom
  85.  *     procedure.
  86.  *
  87.  *     NOTE: When adding additional values an enumerated type must be added
  88.  *           to the REGISTRYENTRIES enumerated type in the snaccah.h header
  89.  *           file.
  90.  */
  91. char RegistryEntries[InvalidRegistryEntry][InvalidRegistryInformation][255] =
  92.     { /* Registry Key  Registry Value  Registry Data */
  93.  
  94.     /* Transport Registry Entry */
  95.     "SOFTWARE\\Microsoft\\SnaBase\\Parameters",
  96.     "Transports",
  97.     "\0",
  98.  
  99.     /* SNA Sponsors Registry Entry */
  100.     "SOFTWARE\\Microsoft\\SnaBase\\Parameters",
  101.     "Sponsors",
  102.     "\0",
  103.  
  104.     /* SNA Domain Registry Entry */
  105.     "SOFTWARE\\Microsoft\\SnaBase\\Parameters", 
  106.     "SnaDomain", 
  107.     "\0",
  108.  
  109.     /* Windows Type Registry Entry */
  110.     "SOFTWARE\\Microsoft\\SNA Server\\CurrentVersion",
  111.     "ClientType",
  112.     "Windows 95",
  113.  
  114.     /* Windows Type Registry Entry */
  115.     "SOFTWARE\\Microsoft\\SNA Server\\CurrentVersion",
  116.     "SNAVersion",
  117.     "2.11"
  118.  
  119.     } ;
  120.  
  121.  
  122.  
  123. /*
  124.  * REGISTRY REMOVE STRINGS
  125.  *
  126.  *     This table of registry entries is used when creating the registry keys
  127.  *     which are added to the registry during the custom action setup.
  128.  *
  129.  *     DESCRIPTION: The entries of this array consist of:
  130.  *                  Registry Key, Registry Value, Registry Data
  131.  *
  132.  *     The Registry Data is setup during the initialization of this custom
  133.  *     procedure.
  134.  *
  135.  *     NOTE: When adding additional values an enumerated type must be added
  136.  *           to the REGISTRYREMOVEENTRIES enumerated type in the snaccah.h header
  137.  *           file.  Caution must be taken for the order of entries in this array.
  138.  *           The 
  139.  */
  140. char RegistryRemoveEntries[InvalidRemoveRegistryEntry][InvalidRegistryParam][255] =
  141.     { /* Registry Key  Registry Value  Registry Data */
  142.  
  143.     /* Parameters Registry Key */
  144.     "SOFTWARE\\Microsoft\\SnaBase",
  145.     "Parameters",
  146.  
  147.     /* SnaBase Registry Key */
  148.     "SOFTWARE\\Microsoft",
  149.     "SnaBase",
  150.  
  151.     /* Setup Registry Key */
  152.     "SOFTWARE\\Microsoft\\SNA Server\\CurrentVersion", 
  153.     "Setup", 
  154.  
  155.     /* CurrentVersion Registry Key */
  156.     "SOFTWARE\\Microsoft\\SNA Server", 
  157.     "CurrentVersion", 
  158.  
  159.     /* Sna Server Registry Key */
  160.     "SOFTWARE\\Microsoft", 
  161.     "SNA Server", 
  162.  
  163.     } ;
  164.  
  165.  
  166. /*
  167.  * REGISTRY KEYS TO BE INSTALLED
  168.  *
  169.  *     This table of booleans values can be used to indicate whether any of the 
  170.  *     
  171.  */
  172. BOOL RegistryKeysToInstall[InvalidRegistryEntry] = 
  173.     { /* Determines if the Key is to be setup in the registry */
  174.     TRUE,
  175.     TRUE,
  176.     TRUE,
  177.     TRUE,
  178.     TRUE
  179.     } ;
  180.  
  181.  
  182. /* 
  183.  * Error Text for Popup Message Boxes
  184.  */
  185. char SetupErrors[InvalidErrorType][InvalidPopupStrings][255] = 
  186.               { /* Window Title */             /* Error Message */
  187.             "REGISTRATION ERROR",           "ERROR - unable to add to the registry!\0",
  188.             "PROTOCOL ERROR",               "ERROR - you must specify at least one protocol!\0",
  189.             "DOMAIN NAME ERROR",            "ERROR - you must specify a Domain Name!\0",
  190.             "PRIMARY SERVER ERROR",         "ERROR - you must specify a Primary Remote SNA Server Name!\0",
  191.             "PLEASE STOP SNA COMPONENTS",   "ERROR - you must exit setup and stop all SNA Server Components!\0",
  192.             "SNA COMPONENT RUNNING",        "ERROR - One of the SNA Base components "
  193.                             "is running, would you like to stop all SNA Base Components?\0",
  194.             "ODBC INSTALLATION ERROR",    "Unable to install ODBC Administrator!\0"
  195.               } ;
  196.  
  197.  
  198.  
  199. /* 
  200.  * Help Text for Popup Message Boxes (Windows NT only)
  201.  */
  202. char SetupHelp[InvalidErrorType][InvalidPopupStrings][500] = 
  203.               { /* Window Title */             /* Help Message */
  204.             "CLIENT MODE HELP",     "Select Local to connect to an SNA Server on the same network domain or "
  205.                         "SNA Server subdomain as your client computer. You will be prompted for "
  206.                         "a domain or subdomain name.  Select Remote if the SNA Server is not in "
  207.                         "the same domain or subdomain as your client computer. You will be prompted"
  208.                         " for the computer names of the primary and backup remote servers.  Contact "
  209.                         "your SNA Server administrator if you need assistance with these options.\0",
  210.             "PROTOCOL HELP",        "If your machine is using TCP/IP or SPX/IPX to communicate with SNA Server,"
  211.                         " select one of these protocols for best performance.  If you are using "
  212.                         "NetBEUI, you must select Named Pipes.\0",
  213.             "LOCAL CLIENT HELP",    "Provides a place for you to type the name of the local Windows NT network "
  214.                         "domain or SNA Server subdomain.  Contact your SNA Server administrator if"
  215.                         " you do not know the name of your domain.\0",
  216.             "REMOTE CLIENT HELP",   "Provides a place for you to type the name of a primary SNA server and a "
  217.                         "place for you to type the name of a backup SNA server.  Contact you SNA "
  218.                         "Server administrator if you do not know the names of the SNA servers.\0"
  219.               } ;
  220.  
  221.  
  222. /*
  223.  * GLOBAL DATA VARIABLES
  224.  */
  225.  
  226. BOOL ExitRequested = FALSE ;    /* Indicates the user has requested to exit setup */
  227. BOOL BackRequested = FALSE ;    /* Indicates the user has requested to return to the previous dialog */
  228. BOOL TCPSelected   = FALSE ;    /* Indicates the user has selected TCP as the transport */
  229.  
  230. char SnaDomainName[255] ;    /* Initially setup as the default domain name from the registry */
  231. char Sponsors[255] ;        /* The sum of sponsors selected separated by a space */
  232. char Transports[255] ;        /* The sum of Transports selected separated by a space, (currently only 1) */
  233.  
  234. char InstallPath[255];        /* The path to the source setup directory */
  235. char DestinationPath[255];    /* The path to the destination setup directory */
  236. char HelpFileNameAndPath[255];    /* The entire path to the help file and help file name */
  237. char WindowsSystemPath[255];    /* The path to the destination windows\system directory */
  238.  
  239. BOOL Windows95;            /* True = WINDOWS 95   False = WINDOWS NT */
  240. int  InstalledApps = 0;        /* The total number of installed applications (ODBC, 3270, 5250, AFTP) */
  241.  
  242. char ClientInstalledText[] = "The setup program has detected a copy of the NT SNA Client installed "
  243.                  "on your computer.  Please exit setup and remove the NT Client before installing "
  244.                  "the Windows 95 Client for SNA Server.";
  245.  
  246. HWND hDlg ;            /* The handle to the desktop window */
  247. HINSTANCE hInstance ;        /* The instance handle */
  248.  
  249.  
  250. /*
  251. **      Purpose:
  252. **              Custom Action Handler for DetectMinimumHardware action (sample).
  253. **      Arguments:
  254. **              pcd   : Ptr to class data.
  255. **              pod   : Ptr to object data.
  256. **              camf  : Custom action member function type.
  257. **              pcamfd: Ptr to custom action member function data
  258. **                      (variable size, depends on camf type).
  259. **      Returns:
  260. **              For all but camfInitialize, it returns rcDoDefault.  For
  261. **              camfInitialize, it returns rcFail or rcDoDefault.
  262. **      Notes:
  263. **              REVIEW: Should get its message strings and definition of 'minimum'
  264. **              from the .STF table data, but we will hardcode it here for simplicity.
  265. **
  266. ***************************************************************************/
  267. RC FAR PASCAL DetectMinimumHardware ( PCD pcd, POD pod, CAMF camf,
  268.                 PCAMFD pcamfd, SZ szData )
  269. {
  270.     static BOOL fDetectHardwareInitialized = fFalse;
  271.  
  272.     Unused(pcd);
  273.     Unused(pod);
  274.     Unused(pcamfd);
  275.     Unused(szData);
  276.  
  277.     if (camf == camfInitializeObject)
  278.         {
  279.         /* REVIEW: Replace the sample hardware tests below with your
  280.         *       own requirements.
  281.         */
  282.         if (!fDetectHardwareInitialized
  283.             && (GetWindowsMajorVersion() < 3
  284.                 || (GetWindowsMajorVersion() == 3
  285.                     && GetWindowsMinorVersion() < 10)
  286.                 || GetProcessorType() == cpu8086
  287.                 || GetProcessorType() == cpu80186
  288.                 || GetProcessorType() == cpu80286
  289.                 || (GetScreenHeight() < 351 && GetScreenWidth() < 641)))
  290.             {
  291.             fDetectHardwareInitialized = fTrue;
  292.             DoMsgBox(STR_DETECT_MSG, STR_DETECT_TITLE,
  293.                     MB_OK | MB_ICONEXCLAMATION);
  294.             return (rcFail);
  295.             }
  296.         fDetectHardwareInitialized = fTrue;
  297.         }
  298.  
  299.     return (rcDoDefault);
  300. }
  301.  
  302.  
  303. /*
  304.  *  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
  305.  *
  306.  *  PURPOSE:  Processes messages for the main window.  This function is used to
  307.  *            for creating a dummy window which has a new extended window class
  308.  *            registered so dialog boxes in Windows NT can have the same look
  309.  *            as the Windows 95 dialog boxes.
  310.  *
  311.  *  MESSAGES: None
  312.  *
  313.  *
  314.  */
  315. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  316. {
  317.     return (DefWindowProc(hWnd, message, wParam, lParam));
  318. }
  319.  
  320.  
  321. /*==========================================================================*
  322.  *  FUNCTION: CreateInvisibleWindow(void)
  323.  *
  324.  *  PURPOSE:  This function creates a parent window with a registered class
  325.  *            which can be used as the parent window for dialog boxes.
  326.  *
  327.  *  MESSAGES: None
  328.  *
  329.  *==========================================================================*/
  330. void CreateInvisibleWindow(void)
  331. {
  332.     hDlg = GetDesktopWindow() ;
  333.     hInstance = (HINSTANCE) GetModuleHandle("SETUPCLI.DLL") ;
  334.  
  335. /*
  336.     MSG     msg ;
  337.     HANDLE  hMod; 
  338.     FARPROC proc; 
  339.     char  szAppName[20] = "TestApp" ;
  340.     DWORD LastError ;
  341.     WNDCLASSEX wcex;
  342.     hMod = GetModuleHandle ("USER32"); 
  343.     proc = GetProcAddress (hMod, "RegisterClassExA");
  344.  
  345.     hInstance = (HINSTANCE) GetModuleHandle("SETUPCLI.DLL") ;
  346.  
  347.     if (hInstance != NULL) 
  348.     {
  349.         wcex.style         = CS_HREDRAW | CS_VREDRAW;
  350.         wcex.lpfnWndProc   = (WNDPROC)WndProc;
  351.         wcex.cbClsExtra    = 0;
  352.         wcex.cbWndExtra    = 0;
  353.         wcex.hInstance     = hInstance;
  354.         wcex.hIcon         = 0;
  355.         wcex.hCursor       = 0;
  356.         wcex.hbrBackground = 0;
  357.         wcex.lpszMenuName  = 0;
  358.         wcex.lpszClassName = szAppName;
  359.  
  360.         wcex.cbSize = sizeof(WNDCLASSEX);
  361.         wcex.hIconSm = 0;
  362.     }
  363.     LastError = RegisterClassEx(&wcex);
  364.     hDlg =  CreateWindow(szAppName, szAppName, WS_OVERLAPPEDWINDOW,
  365.         CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
  366.         NULL, NULL, hInstance, NULL);
  367.     ShowWindow(hDlg,SW_HIDE) ;
  368.     while ( PeekMessage(&msg, hDlg, 0, 0xffffffff, PM_REMOVE) )
  369.         {
  370.         DispatchMessage(&msg);
  371.         }
  372.     LastError = GetLastError();
  373. */
  374. }
  375.  
  376.  
  377. /*==========================================================================*
  378.  * Destroy Invisible Window
  379.  *==========================================================================*/
  380. void DestroyInvisibleWindow(void)
  381. {
  382. /*      DestroyWindow(hDlg) ; */
  383. }
  384.  
  385. #ifndef ISVBUILD
  386. /*==========================================================================*
  387.  * Initialize the position of a dialog box.  NOTE the size of the dialog box
  388.  * must be passed in!
  389.  *==========================================================================*/
  390. void InstallSNAFontFiles(void)
  391. {
  392.     int    LastError;
  393.     char   StrBuf[400];
  394.     char   StrBuf2[400];
  395.     char   StrBuf3[400];
  396.     static char szFontFile[255] = "";
  397.     /* Determine Windows System Path */
  398.     lstrcpy(StrBuf3, WindowsSystemPath);
  399.     lstrcpy(StrBuf, StrBuf3);
  400.     lstrcpy(StrBuf2, InstallPath);
  401.     lstrcat(StrBuf2, "system\\ltype.ttf");
  402.     lstrcat(StrBuf3, "ltype.ttf");
  403.  
  404.     /* Copy the LTYPE.TTF file to the windows\system directory */
  405.     CopyFileA((LPSTR) StrBuf2, (LPSTR) StrBuf3, TRUE);
  406.  
  407.     lstrcpy(szFontFile, StrBuf);
  408.     lstrcat(szFontFile, "ltype.fot");
  409.     LastError = (BOOL) CreateScalableFontResource(0,
  410.                                   szFontFile,
  411.                               "ltype.ttf",
  412.                               StrBuf);
  413.     AddFontResource(szFontFile);
  414. }
  415. #endif
  416.  
  417.  
  418. /*==========================================================================*
  419.  * Initialize the position of a dialog box.  NOTE the size of the dialog box
  420.  * must be passed in!
  421.  *==========================================================================*/
  422. void initDlgPosWnd(HWND hDlg)
  423. {
  424.     RECT  dialogRect;
  425.     int   MaxX ; 
  426.     int   MaxY ;
  427.     int   DialogWidth ;
  428.     int   DialogHeight ;
  429.  
  430.     GetWindowRect(hDlg, (LPRECT) &dialogRect);
  431.  
  432.     DialogWidth  = dialogRect.right - dialogRect.left ;
  433.     DialogHeight = dialogRect.bottom - dialogRect.top ;
  434.  
  435.     MaxX = GetSystemMetrics(SM_CXSCREEN) ;
  436.     MaxY = GetSystemMetrics(SM_CYSCREEN) ;
  437.  
  438.     dialogRect.left   = (MaxX - DialogWidth) / 2 ; 
  439.     dialogRect.top    = (MaxY - DialogHeight) / 2 ; 
  440.  
  441.     MoveWindow(hDlg, (int)dialogRect.left, (int)dialogRect.top,
  442.            DialogWidth, DialogHeight, FALSE);
  443.  
  444. }
  445.  
  446. /*=========================================================================*
  447.  * DisplayError - generic error display function
  448.  *=========================================================================*/
  449. void DisplayError(ERRORTYPE ErrorIndex)
  450. {
  451.     MessageBox(GetActiveWindow(), 
  452.            SetupErrors[ErrorIndex][WindowMessage], 
  453.            SetupErrors[ErrorIndex][WindowTitle],
  454.            MB_OK|MB_ICONEXCLAMATION);
  455. }
  456.  
  457. /*=========================================================================*
  458.  * Display help - generic help display function
  459.  *=========================================================================*/
  460. void DisplayHelp(HELPTYPE HelpIndex)
  461. {
  462.     MessageBox(GetActiveWindow(), 
  463.            SetupHelp[HelpIndex][WindowMessage], 
  464.            SetupHelp[HelpIndex][WindowTitle],
  465.            MB_OK|MB_ICONINFORMATION);
  466. }
  467.  
  468.  
  469. /*========================================================================*
  470.  * ExitYesNo Dialog Procedure
  471.  *========================================================================*/
  472.  /*
  473.  * Turn off the warning "xxx: unreferenced formal parameter"
  474.  */
  475. #pragma warning (disable : 4100)
  476. BOOL CALLBACK
  477. ExitYesNoDlg(
  478.     HWND hDlg,
  479.     UINT message,
  480.     WPARAM wParam,
  481.     LPARAM lParam)
  482. {
  483.  
  484.     switch (message)
  485.     {
  486.         case WM_CLOSE:
  487.             EndDialog(hDlg, 0) ;
  488.             return TRUE ;
  489.         
  490.         case WM_INITDIALOG:
  491.             initDlgPosWnd(hDlg);
  492.             ExitRequested = FALSE ;
  493.             return TRUE ;
  494.  
  495.         case WM_COMMAND:
  496.             switch (LOWORD(wParam))
  497.             {
  498.                 case IDC_RESUME:
  499.                     ExitRequested = FALSE ;
  500.                     EndDialog(hDlg, 0) ;
  501.                     return TRUE ;
  502.  
  503.                 case IDC_EXIT:  
  504.                     ExitRequested = TRUE ;
  505.                     EndDialog(hDlg, 0) ;
  506.                     return TRUE ;
  507.             break;
  508.             }
  509.         break ;
  510.     }
  511.     return FALSE ;
  512. }
  513.  
  514. /*========================================================================*
  515.  * License Dialog Procedure
  516.  *========================================================================*/
  517.  /*
  518.  * Turn off the warning "xxx: unreferenced formal parameter"
  519.  */
  520. #pragma warning (disable : 4100)
  521. BOOL CALLBACK
  522. LicenseDlg(
  523.     HWND hDlg,
  524.     UINT message,
  525.     WPARAM wParam,
  526.     LPARAM lParam)
  527. {
  528.  
  529.     switch (message)
  530.     {
  531.         case WM_CLOSE:
  532.             EndDialog(hDlg, 0) ;
  533.             return TRUE ;
  534.         
  535.         case WM_INITDIALOG:
  536.             initDlgPosWnd(hDlg);
  537.             ExitRequested = FALSE ;
  538.             return TRUE ;
  539.  
  540.         case WM_COMMAND:
  541.             switch (LOWORD(wParam))
  542.             {
  543.                 case IDC_CONTINUE:
  544.                     ExitRequested = FALSE ;
  545.                     EndDialog(hDlg, 0) ;
  546.                     return TRUE ;
  547.  
  548.                 case IDC_EXIT:
  549.                     ExitRequested = TRUE;
  550.                     EndDialog(hDlg, 0) ;
  551.                     return FALSE ;
  552.             break;
  553.             }
  554.         break ;
  555.     }
  556.     return FALSE ;
  557. }
  558.  
  559. /*=========================================================================*
  560.  * ExitYesNo - Exit Yes or No
  561.  *=========================================================================*/
  562. void ExitYesNoMB(void)
  563. {
  564.     char szAppName[13] = "EXITYESNO" ;
  565.     if (Windows95)
  566.     {
  567.         lstrcat(szAppName,"EX");
  568.     }
  569.     (void)DialogBox(hInstance,
  570.             szAppName,
  571.             hDlg,
  572.             ExitYesNoDlg) ;
  573. }
  574.  
  575. /*=========================================================================*
  576.  * Add to Registry - this function adds a single entry to the registry from
  577.  *                   values passed in the following parameters:
  578.  *
  579.  *                   RegistryKey  - full path of the registry key
  580.  *                   RegistryName - name of the registry entry
  581.  *                   RegistryData - Data to be placed in the registry
  582.  *
  583.  *=========================================================================*/
  584. int AddRegistryEntry (
  585.               LPSTR RegistryKey,
  586.               LPSTR RegistryName,
  587.               LPSTR RegistryData )
  588. {
  589.     HKEY   hKey ;
  590.     DWORD  iDisposition ;
  591.     int    DataLength = 0 ;
  592.  
  593.     DataLength += lstrlen(RegistryData) ;
  594.     RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  595.                RegistryKey,
  596.                0,
  597.                NULL,
  598.                REG_OPTION_NON_VOLATILE,
  599.                KEY_WRITE,
  600.                NULL,
  601.                &hKey,
  602.                (LPDWORD) &iDisposition) ;
  603.     RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  604.              RegistryKey,
  605.              0,
  606.              KEY_WRITE,
  607.              &hKey) ;
  608.     DataLength++;
  609.     if (ERROR_SUCCESS != 
  610.         RegSetValueEx(hKey,
  611.               RegistryName,
  612.               0,
  613.               REG_SZ,
  614.               RegistryData,
  615.               DataLength)) DisplayError(RegistrationError) ;
  616.     RegCloseKey(hKey) ;
  617.     return (0) ;
  618. }
  619.  
  620. /*=========================================================================*
  621.  * Update Registry - This function updates the registry with all new SNA
  622.  *                   client entries.
  623.  */
  624. int UpdateRegistry(void)
  625. {
  626.     REGISTRYENTRIES RegistryEntry;
  627.  
  628.     for (RegistryEntry=TransportRegistry; RegistryEntry<InvalidRegistryEntry; RegistryEntry++)
  629.     {
  630.         if (RegistryKeysToInstall[RegistryEntry])
  631.             AddRegistryEntry ( RegistryEntries[RegistryEntry][RegistryKey],
  632.                        RegistryEntries[RegistryEntry][RegistryValue],
  633.                        RegistryEntries[RegistryEntry][RegistryData] );
  634.     }
  635.     return 0 ;
  636. }
  637.  
  638. /*=========================================================================*
  639.  * Remove Registry - This function removes all registry entries created by
  640.  *                   this DLL.
  641.  */
  642. void RemoveRegistry(void)
  643. {
  644.     HKEY   hKey ;
  645.     REGISTRYREMOVEENTRIES RegistryRemoveEntry;
  646.     for (RegistryRemoveEntry=SystemSnaParameters; 
  647.          RegistryRemoveEntry<InvalidRemoveRegistryEntry; 
  648.          RegistryRemoveEntry++)
  649.     {
  650.         RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  651.                  RegistryRemoveEntries[RegistryRemoveEntry]
  652.                           [RegistryRemoveKey],
  653.                  0,
  654.                  KEY_WRITE,
  655.                  &hKey) ;
  656.         RegDeleteKey(hKey, RegistryRemoveEntries[RegistryRemoveEntry]
  657.                             [RegistryRemoveSubKey]);
  658.         RegCloseKey(hKey) ;
  659.     }
  660. }
  661.  
  662.  
  663.  
  664. /*=========================================================================*
  665.  * Remove Ini and Trace Files - This function removes .ini and trace files 
  666.  *                              created by the Client.
  667.  * 
  668.  */
  669. BOOL RemoveIniAndTraceFiles(void)
  670. {
  671.     char TraceFiles[300] = "";
  672.     WIN32_FIND_DATA CurrentFile;
  673.     HANDLE FileHandle;
  674.     char FileNameAndPath[MAX_PATH];
  675.     int i;
  676.     
  677.     /*
  678.      * Remove all Trace files (.trc)
  679.      */
  680.     lstrcpy(TraceFiles, DestinationPath);
  681.     lstrcat(TraceFiles, "traces\\*.trc");
  682.     while (INVALID_HANDLE_VALUE != 
  683.           (FileHandle = FindFirstFile(TraceFiles, (LPWIN32_FIND_DATA) &CurrentFile)))
  684.     {
  685.         strcpy(FileNameAndPath, DestinationPath);
  686.         strcat(FileNameAndPath, "traces\\");
  687.         strcat(FileNameAndPath, CurrentFile.cFileName);
  688.         if (!DeleteFile(FileNameAndPath))
  689.         {
  690.             FindClose(FileHandle);
  691.             break;
  692.         }
  693.         FindClose(FileHandle);
  694.     }
  695.     
  696.     /*
  697.      * Remove applet ini file (RUMBA.INI)
  698.      */
  699.     strcpy(FileNameAndPath, DestinationPath);
  700.     strcat(FileNameAndPath, "system\\");
  701.     strcat(FileNameAndPath, "RUMBA.INI");
  702.     DeleteFile(FileNameAndPath);
  703.  
  704.     /*
  705.      * Remove applet ini file (WIN5250.INI)
  706.      */
  707.     strcpy(FileNameAndPath, DestinationPath);
  708.     strcat(FileNameAndPath, "system\\");
  709.     strcat(FileNameAndPath, "WIN5250.INI");
  710.     DeleteFile(FileNameAndPath);
  711.  
  712.     /*
  713.      * Remove SNA dump file (SNADUMP.LOG)
  714.      */
  715.     strcpy(FileNameAndPath, DestinationPath);
  716.     strcat(FileNameAndPath, "traces\\");
  717.     strcat(FileNameAndPath, "SNADUMP.LOG");
  718.     DeleteFile(FileNameAndPath);
  719.  
  720.     /*
  721.      * Remove windows\system files 
  722.      */
  723.     for (i = 0; strcmp(WinSysRemovefile[i],""); i++)
  724.     {
  725.         strcpy(FileNameAndPath, WindowsSystemPath);
  726.         strcat(FileNameAndPath, WinSysRemovefile[i]);
  727.         DeleteFile(FileNameAndPath);
  728.     }
  729.  
  730.     return TRUE;
  731. }
  732.  
  733.  
  734.  
  735. /*========================================================================*
  736.  * Get the local system parameters.
  737.  *========================================================================*/
  738. BOOL
  739. SetupSystemParameters(PCD pcd, POD pod, CAMF camf,
  740.               PCAMFD pcamfd, SZ szData ) 
  741. {
  742.     HKEY   hKey ;
  743.     char   HelpFileName[]        = "SETUPCLI.HLP";
  744.     LPSTR  DomainKeyNT          = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\0";
  745.     LPSTR  DomainSubKeyNT       = "CachePrimaryDomain\0";
  746.     LPSTR  DomainKeyWin95       = "SYSTEM\\CurrentControlSet\\Services\\MSNP32\\NetworkProvider\0";
  747.     LPSTR  DomainSubKeyWin95    = "AuthenticatingAgent\0";
  748.     LPSTR  DomainKey;
  749.     LPSTR  DomainSubKey;
  750.     LPSTR  WindowsKeyNT         = "SOFTWARE\\Microsoft\\Windows NT\0";
  751.     LPSTR  WindowsKeyWin95      = "SOFTWARE\\Microsoft\\Windows\0";
  752.     char   szBuffer[256] ;
  753.     BOOL   ErrorReturn = TRUE ;
  754.     DWORD  dType ;
  755.     DWORD  dSize = 255 ;
  756.     
  757.     /*
  758.      * Determine the installation path and destination path
  759.      */
  760.     lstrcpy(InstallPath, pcd->rgchStfSrcDir);
  761.     lstrcpy(DestinationPath, pod->szDstDir);
  762.     lstrcpy(HelpFileNameAndPath, InstallPath);
  763.     lstrcat(HelpFileNameAndPath, HelpFileName);
  764.     lstrcpy(WindowsSystemPath, pcd->rgchStfSys16Dir);
  765.     lstrcpy(WindowsSystemPath, pcd->rgchStfSysDir);
  766.  
  767.     /* 
  768.      * Determine Windows Version Currently Installed
  769.      */
  770.     if (0 > (int) GetVersion())
  771.     {
  772.         Windows95 = TRUE; 
  773.         DomainKey = DomainKeyWin95 ;
  774.         DomainSubKey = DomainSubKeyWin95;
  775.         RegCloseKey(hKey) ;
  776.     }
  777.     else
  778.     {
  779.         Windows95 = FALSE ;
  780.         DomainKey = DomainKeyNT ;
  781.         DomainSubKey = DomainSubKeyNT;
  782.         RegCloseKey(hKey) ;
  783.     }
  784.  
  785.     /* 
  786.      * Locate default domain name from registry
  787.      */
  788.     RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  789.              DomainKey,
  790.              0,
  791.              KEY_READ,
  792.              &hKey) ;
  793.     if (ERROR_SUCCESS == RegQueryValueEx(hKey, 
  794.                          DomainSubKey,
  795.                          0,
  796.                          (LPDWORD) &dType,
  797.                          szBuffer,
  798.                          (LPDWORD) &dSize))
  799.     {
  800.         lstrcpy(SnaDomainName, szBuffer) ;
  801.     }
  802.     RegCloseKey(hKey) ;
  803.     return ErrorReturn;
  804. }
  805.  
  806.  
  807. /*========================================================================*
  808.  * Check to see if the NT SNA Client is installed
  809.  *========================================================================*/
  810. BOOL
  811. CheckForNTClient(void)
  812. {
  813.     HKEY   hKey ;
  814.     BOOL   NTClientInstalled = FALSE;
  815.     LPSTR  NTClientKey        = "SYSTEM\\CurrentControlSet\\Services\\SnaBase\\Linkage";
  816.     LPSTR  NTClientSubKey        = "OtherDependencies";
  817.     char   szBuffer[256] ;
  818.     DWORD  dType ;
  819.     DWORD  dSize = 255 ;
  820.  
  821.  
  822.     /* 
  823.      * Check to see if the NT Client is installed
  824.      */
  825.     RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  826.              NTClientKey,
  827.              0,
  828.              KEY_READ,
  829.              &hKey);
  830.     if (ERROR_SUCCESS == RegQueryValueEx(hKey, 
  831.                          NTClientSubKey,
  832.                          0,
  833.                          (LPDWORD) &dType,
  834.                          szBuffer,
  835.                          (LPDWORD) &dSize))
  836.     {
  837.         NTClientInstalled = TRUE;
  838.     }
  839.  
  840.     RegCloseKey(hKey);
  841.     return NTClientInstalled;
  842. }
  843.  
  844.  
  845. /*========================================================================*
  846.  * Get Installed Protocols.  Currently only the following are detected:
  847.  *                              Microsoft\\ Networking
  848.  *                              Novell Networking (IPX/SPX)
  849.  *                              TCPIP Networking
  850.  *========================================================================*/
  851. void
  852. GetInstalledProtocols(BOOL *MSFT_protocol, 
  853.               BOOL *NOVELL_protocol, 
  854.               BOOL *TCPIP_protocol) 
  855. {
  856.     HINSTANCE hLib;
  857.     *MSFT_protocol = TRUE ;
  858.     *NOVELL_protocol = TRUE ;
  859.     *TCPIP_protocol = TRUE ;
  860.  
  861.     /*
  862.      * We'll do step-by-step checks for each NOS, starting with
  863.      * Lan Manager, followed by Netware, etc.
  864.      */
  865.  
  866.    /*
  867.     * Netware...
  868.     */
  869.    {
  870.       DWORD     dwRc;
  871.       WSADATA   wsaData = {0};
  872.       SOCKET    sSocket = INVALID_SOCKET;
  873.       FARPROC   SockProc    = NULL;
  874.       FARPROC   pfnProc     = NULL;
  875.  
  876.  
  877.       if ( (( hLib = LoadLibrary( NWDLL )) == NULL )
  878.  
  879.     || (( pfnProc = GetProcAddress( hLib, NWFUNC )) == NULL )
  880.  
  881.     || (( dwRc = (*pfnProc)( MAKEWORD( WINSOCKET_MAJOR,
  882.                        WINSOCKET_MINOR ),
  883.                  &wsaData )) != 0 )
  884.      )
  885.       {
  886.      *NOVELL_protocol = FALSE;
  887.       }
  888.       else if (hLib) {
  889.  
  890.      if (pfnProc && !dwRc) {  /* try to open an IPX socket */
  891.  
  892.         if (( SockProc = GetProcAddress( hLib, "socket" )) != NULL ) {
  893.  
  894.            if (( sSocket = (*SockProc)( AF_NS, SOCK_DGRAM, NSPROTO_IPX )) == INVALID_SOCKET ) {
  895.           *NOVELL_protocol = FALSE;
  896.  
  897.            } else {
  898.           if (( SockProc = GetProcAddress( hLib, "closesocket" )) != NULL ) {
  899.              (*SockProc)( sSocket );
  900.           }
  901.            }
  902.         }
  903.      }
  904.      FreeLibrary( hLib );
  905.      hLib = NULL;
  906.       }
  907.    }
  908.  
  909.    /*
  910.     * TCP/IP...
  911.     */
  912.    {
  913.       DWORD     dwRc;
  914.       WSADATA   wsaData = {0};
  915.       SOCKET    sSocket = INVALID_SOCKET;
  916.       FARPROC   SockProc      = NULL;
  917.       FARPROC   pfnProc       = NULL;
  918.  
  919.  
  920.       if ( (( hLib = LoadLibrary( IPDLL )) == NULL )
  921.  
  922.     || (( pfnProc = GetProcAddress( hLib, IPFUNC )) == NULL )
  923.  
  924.     || (( dwRc = (*pfnProc)( MAKEWORD( WINSOCKET_MAJOR,
  925.                        WINSOCKET_MINOR ),
  926.                  &wsaData )) != 0 )
  927.      )
  928.       {
  929.      *TCPIP_protocol = FALSE;
  930.       }
  931.       else if (hLib) {
  932.  
  933.      if (pfnProc && !dwRc) {  /* try to open an IP socket */
  934.  
  935.         if (( SockProc = GetProcAddress( hLib, "socket" )) != NULL ) {
  936.  
  937.            if (( sSocket = (*SockProc)( PF_INET, SOCK_DGRAM, 0 )) == INVALID_SOCKET ) {
  938.           *TCPIP_protocol = FALSE;
  939.  
  940.            } else {
  941.           if (( SockProc = GetProcAddress( hLib, "closesocket" )) != NULL ) {
  942.              (*SockProc)( sSocket );
  943.           }
  944.            }
  945.         }
  946.      }
  947.      FreeLibrary( hLib );
  948.      hLib = NULL;
  949.       }
  950.    }
  951.  
  952. }
  953.  
  954. /*========================================================================*
  955.  * Client Protocol Dialog Box Procedure
  956.  *========================================================================*/
  957.  /*
  958.  * Turn off the warning "xxx: unreferenced formal parameter"
  959.  */
  960. #pragma warning (disable : 4100)
  961. BOOL CALLBACK
  962. ClientProtocolsDlg(
  963.     HWND hDlg,
  964.     UINT message,
  965.     WPARAM wParam,
  966.     LPARAM lParam)
  967. {
  968.     static BOOL MSFT_protocol   = TRUE ;
  969.     static BOOL NOVELL_protocol = TRUE ; 
  970.     static BOOL TCPIP_protocol  = TRUE ;
  971.     char   szTCPDLL[]    = "snacip.dll \0" ;
  972.     char   szNOVELLDLL[] = "snacnw.dll \0" ;
  973.     char   szMSFTDLL[]   = "snaclm.dll \0" ;
  974.     int    DataLength = 0 ;
  975.  
  976.     static const DWORD ClientProtocolsHelpIDs [] = 
  977.     {
  978.         IDC_MSFT,            IDC_MSFT,
  979.         IDC_NOVELL,          IDC_NOVELL,
  980.         IDC_TCPIP,           IDC_TCPIP,
  981.         IDC_CONTINUE,        IDC_CONTINUE,
  982.         IDC_EXIT,            IDC_EXIT,
  983.         0,                   0
  984.     };
  985.  
  986.     switch (message)
  987.     {
  988.         case WM_HELP:
  989.         {
  990.             LPHELPINFO lphi;
  991.             lphi = (LPHELPINFO)lParam;
  992.             if (lphi->iContextType == HELPINFO_WINDOW)
  993.             {
  994.                 WinHelp(lphi->hItemHandle,
  995.                     HelpFileNameAndPath,
  996.                     HELP_WM_HELP,
  997.                     (DWORD) (LPVOID) ClientProtocolsHelpIDs);
  998.             }
  999.             return TRUE ;
  1000.         }
  1001.  
  1002.         case WM_CLOSE:
  1003.             EndDialog(hDlg, 0) ;
  1004.             return TRUE ;
  1005.         
  1006.         case WM_INITDIALOG:
  1007.         {
  1008.             initDlgPosWnd(hDlg);
  1009.                     GetInstalledProtocols(&MSFT_protocol, 
  1010.                                   &NOVELL_protocol, 
  1011.                                   &TCPIP_protocol ) ;
  1012.                     /*
  1013.                      * Enable appropriate check boxes
  1014.                      */
  1015.                     if (!MSFT_protocol) 
  1016.                         EnableWindow(GetDlgItem(hDlg, IDC_MSFT), FALSE) ;
  1017.                     if (!NOVELL_protocol) 
  1018.                         EnableWindow(GetDlgItem(hDlg, IDC_NOVELL), FALSE) ;
  1019.                     if (!TCPIP_protocol) 
  1020.                         EnableWindow(GetDlgItem(hDlg, IDC_TCPIP), FALSE) ;
  1021.                     /*
  1022.                      * Set up the default protocol
  1023.                      */
  1024.                     if (TCPIP_protocol) 
  1025.                         CheckDlgButton(hDlg, IDC_TCPIP, 1) ;
  1026.                     else if (MSFT_protocol) 
  1027.                         CheckDlgButton(hDlg, IDC_MSFT, 1) ;
  1028.                     else if (NOVELL_protocol) 
  1029.                         CheckDlgButton(hDlg, IDC_NOVELL, 1) ;
  1030.                     return TRUE ;
  1031.         }
  1032.  
  1033.         case WM_COMMAND:
  1034.         {
  1035.             switch (LOWORD(wParam))
  1036.             {
  1037.                 case IDC_CONTINUE:
  1038.                     if (!(IsDlgButtonChecked(hDlg, IDC_MSFT)  ||
  1039.                         IsDlgButtonChecked(hDlg, IDC_TCPIP) ||
  1040.                         IsDlgButtonChecked(hDlg, IDC_NOVELL)) )
  1041.                     {
  1042.                         DisplayError(ProtocolError) ;
  1043.                         return TRUE ;
  1044.                     }
  1045.                     if (IsDlgButtonChecked(hDlg, IDC_MSFT))
  1046.                     {
  1047.                         DataLength += lstrlen(szMSFTDLL) ;
  1048.                         lstrcat(RegistryEntries[TransportRegistry]
  1049.                                        [RegistryData],szMSFTDLL) ;
  1050.                     }
  1051.                     if (IsDlgButtonChecked(hDlg, IDC_TCPIP))
  1052.                     {
  1053.                         TCPSelected = TRUE;
  1054.                         DataLength += lstrlen(szTCPDLL) ;
  1055.                         lstrcat(RegistryEntries[TransportRegistry]
  1056.                                        [RegistryData],szTCPDLL);
  1057.                     }
  1058.                     if (IsDlgButtonChecked(hDlg, IDC_NOVELL))
  1059.                     {
  1060.                         DataLength += lstrlen(szNOVELLDLL) ;
  1061.                         lstrcat(RegistryEntries[TransportRegistry]
  1062.                                        [RegistryData],szNOVELLDLL) ;
  1063.                     }
  1064.                     /* Indicate the Protocols Registry Key should be setup */
  1065.                     RegistryKeysToInstall[TransportRegistry] = TRUE ;
  1066.                     EndDialog(hDlg, 0) ;
  1067.                     return TRUE ;
  1068.  
  1069.                 case IDC_HELPT:  
  1070.                     DisplayHelp(ProtocolHelp) ;
  1071.                     return TRUE ;
  1072.  
  1073.                 case IDC_EXIT:  
  1074.                     ExitYesNoMB() ;
  1075.                     if (ExitRequested) EndDialog(hDlg, 0) ;
  1076.                     return TRUE ;
  1077.  
  1078.                 break ;
  1079.             }
  1080.         }
  1081.         break ;
  1082.     }
  1083.     return FALSE ;
  1084. }
  1085.  
  1086.  
  1087. /*========================================================================*
  1088.  * Remote Client Dialog Box Procedure
  1089.  *========================================================================*/
  1090.  /*
  1091.  * Turn off the warning "xxx: unreferenced formal parameter"
  1092.  */
  1093. #pragma warning (disable : 4100)
  1094. BOOL CALLBACK
  1095. RemoteClientDlg(
  1096.     HWND hDlg,
  1097.     UINT message,
  1098.     WPARAM wParam,
  1099.     LPARAM lParam)
  1100. {
  1101.     char   TempString[255] = "" ;
  1102.     int    DataLength = 0 ;
  1103.  
  1104.     static const DWORD RemoteClientHelpIDs [] = 
  1105.     {
  1106.         IDC_PRIMARY,         IDC_PRIMARY,
  1107.         IDC_BACKUP,          IDC_BACKUP,
  1108.         IDC_CONTINUE,        IDC_CONTINUE,
  1109.         IDC_EXIT,            IDC_EXIT,
  1110.         IDC_BACK,            IDC_BACK,
  1111.         0,                   0
  1112.     };
  1113.  
  1114.     switch (message)
  1115.     {
  1116.         case WM_HELP:
  1117.         {
  1118.             LPHELPINFO lphi;
  1119.  
  1120.             lphi = (LPHELPINFO)lParam;
  1121.             if (lphi->iContextType == HELPINFO_WINDOW)
  1122.             {
  1123.                 WinHelp(lphi->hItemHandle,
  1124.                     HelpFileNameAndPath,
  1125.                     HELP_WM_HELP,
  1126.                     (DWORD) (LPVOID) RemoteClientHelpIDs);
  1127.             }
  1128.             return TRUE ;
  1129.         }
  1130.  
  1131.         case WM_CLOSE:
  1132.             EndDialog(hDlg, 0) ;
  1133.             return TRUE ;
  1134.         
  1135.         case WM_INITDIALOG:
  1136.             initDlgPosWnd(hDlg);
  1137.             BackRequested = FALSE ;
  1138.             return TRUE ;
  1139.  
  1140.         case WM_COMMAND:
  1141.             switch (LOWORD(wParam))
  1142.             {
  1143.                 case IDC_CONTINUE:
  1144.                     if (!GetDlgItemText(hDlg,
  1145.                                 IDC_PRIMARY,
  1146.                                 RegistryEntries[SponsorRegistry]
  1147.                                        [RegistryData],
  1148.                                 255))
  1149.                     {
  1150.                         DisplayError(PrimaryServerError) ;
  1151.                         return TRUE ;
  1152.                     }
  1153.                     if (GetDlgItemText(hDlg,
  1154.                                    IDC_BACKUP,
  1155.                                    TempString,
  1156.                                    255))
  1157.                     {
  1158.                         lstrcat(RegistryEntries[SponsorRegistry][RegistryData], " \0") ;
  1159.                         lstrcat(RegistryEntries[SponsorRegistry][RegistryData], TempString) ;
  1160.                     }
  1161.                     RegistryKeysToInstall[SponsorRegistry] = TRUE ;
  1162.                     EndDialog(hDlg, 0) ;
  1163.                     return TRUE ;
  1164.  
  1165.                 case IDC_HELPT:  
  1166.                     DisplayHelp(RemoteClientHelp) ;
  1167.                     return TRUE ;
  1168.  
  1169.                 case IDC_EXIT:  
  1170.                     ExitYesNoMB() ;
  1171.                     if (ExitRequested) EndDialog(hDlg, 0) ;
  1172.                     return TRUE ;
  1173.  
  1174.                 case IDC_BACK:  
  1175.                     BackRequested = TRUE ;
  1176.                     EndDialog(hDlg, 0) ;
  1177.                     return TRUE ;
  1178.  
  1179.                 break ;
  1180.             }
  1181.         break ;
  1182.     }
  1183.     return FALSE ;
  1184. }
  1185.  
  1186. /*========================================================================*
  1187.  * Local Client Dialog Box Procedure
  1188.  *========================================================================*/
  1189.  /*
  1190.  * Turn off the warning "xxx: unreferenced formal parameter"
  1191.  */
  1192. #pragma warning (disable : 4100)
  1193. BOOL CALLBACK
  1194. LocalClientDlg(
  1195.     HWND hDlg,
  1196.     UINT message,
  1197.     WPARAM wParam,
  1198.     LPARAM lParam)
  1199. {
  1200.     int    DataLength = 0 ;
  1201.  
  1202.     static const DWORD LocalClientHelpIDs [] = 
  1203.     {
  1204.         IDC_DOMAIN,          IDC_DOMAIN,
  1205.         IDC_CONTINUE,        IDC_CONTINUE,
  1206.         IDC_EXIT,            IDC_EXIT,
  1207.         IDC_BACK,            IDC_BACK,
  1208.         0,                   0
  1209.     };
  1210.  
  1211.     switch (message)
  1212.     {
  1213.         case WM_HELP:
  1214.         {
  1215.             LPHELPINFO lphi;
  1216.  
  1217.             lphi = (LPHELPINFO)lParam;
  1218.             if (lphi->iContextType == HELPINFO_WINDOW)
  1219.             {
  1220.                 WinHelp(lphi->hItemHandle,
  1221.                     HelpFileNameAndPath,
  1222.                     HELP_WM_HELP,
  1223.                     (DWORD) (LPVOID) LocalClientHelpIDs);
  1224.             }
  1225.             return TRUE ;
  1226.         }
  1227.  
  1228.         case WM_CLOSE:
  1229.             EndDialog(hDlg, 0) ;
  1230.             return TRUE ;
  1231.         
  1232.         case WM_INITDIALOG:
  1233.             initDlgPosWnd(hDlg);
  1234.             SetDlgItemText(hDlg,
  1235.                        IDC_DOMAIN,
  1236.                        SnaDomainName) ;
  1237.             initDlgPosWnd(hDlg);
  1238.             BackRequested = FALSE ;
  1239.             return TRUE ;
  1240.  
  1241.         case WM_COMMAND:
  1242.             switch (LOWORD(wParam))
  1243.             {
  1244.                 case IDC_CONTINUE:
  1245.                     if (!GetDlgItemText(hDlg,
  1246.                                 IDC_DOMAIN,
  1247.                                 RegistryEntries[SnaDomainRegistry]
  1248.                                        [RegistryData],
  1249.                                 255) )
  1250.                     {
  1251.                         DisplayError(DomainNameError);
  1252.                         return TRUE ;
  1253.                     }
  1254.                     RegistryKeysToInstall[SnaDomainRegistry] = TRUE ;
  1255.                     EndDialog(hDlg, 0) ;
  1256.                     return TRUE ;
  1257.  
  1258.                 case IDC_HELPT:  
  1259.                     DisplayHelp(LocalClientHelp) ;
  1260.                     return TRUE ;
  1261.  
  1262.                 case IDC_EXIT:  
  1263.                     ExitYesNoMB() ;
  1264.                     if (ExitRequested) 
  1265.                         EndDialog(hDlg, 0) ;
  1266.                     return TRUE ;
  1267.  
  1268.                 case IDC_BACK:  
  1269.                     BackRequested = TRUE ;
  1270.                     EndDialog(hDlg, 0) ;
  1271.                     return TRUE ;
  1272.  
  1273.                 break ;
  1274.             }
  1275.         break ;
  1276.     }
  1277.     return FALSE ;
  1278. }
  1279.  
  1280. /*========================================================================*
  1281.  * Client Mode Dialog Box Procedure
  1282.  *========================================================================*/
  1283.  /*
  1284.  * Turn off the warning "xxx: unreferenced formal parameter"
  1285.  */
  1286. #pragma warning (disable : 4100)
  1287. BOOL CALLBACK
  1288. ClientModeDlg(
  1289.     HWND hDlg,
  1290.     UINT message,
  1291.     WPARAM wParam,
  1292.     LPARAM lParam)
  1293. {
  1294.     LPSTR  RegistryKey   = "SOFTWARE\\Microsoft\\SnaBase\0";
  1295.     char   RegistryData[255]  = "" ; 
  1296.     LPSTR  ClientModeKey  = "ObjectName" ;   
  1297.     char   szLocal[]      = "LocalSystem\0" ;
  1298.     char   szRemote[]     = "RemoteSystem\0" ;
  1299.     int    DataLength = 0 ;
  1300.     DWORD  LastError ;
  1301.  
  1302.     static const DWORD ClientModeHelpIDs [] = 
  1303.     {
  1304.         IDC_LOCAL,           IDC_LOCAL,
  1305.         IDC_REMOTE,          IDC_REMOTE,
  1306.         IDC_CONTINUE,        IDC_CONTINUE,
  1307.         IDC_EXIT,            IDC_EXIT,
  1308.         0,                   0
  1309.     };
  1310.  
  1311.     static char szLocalClient[50] = "LocalClient" ;
  1312.     static char szRemoteClient[50] = "RemoteClient" ;
  1313.  
  1314.     switch (message)
  1315.     {
  1316.         case WM_HELP:
  1317.         {
  1318.             LPHELPINFO lphi;
  1319.             lphi = (LPHELPINFO)lParam;
  1320.             if (lphi->iContextType == HELPINFO_WINDOW)
  1321.             {
  1322.                 WinHelp(lphi->hItemHandle,
  1323.                         HelpFileNameAndPath,
  1324.                         HELP_WM_HELP,
  1325.                         (DWORD) (LPVOID) ClientModeHelpIDs);
  1326.             }
  1327.             return TRUE ;
  1328.         }
  1329.  
  1330.         case WM_CLOSE:
  1331.             EndDialog(hDlg, 0) ;
  1332.             return TRUE ;
  1333.         
  1334.         case WM_INITDIALOG:
  1335.             initDlgPosWnd(hDlg);
  1336.             if (TCPSelected)
  1337.                 CheckDlgButton(hDlg, IDC_REMOTE, 1) ;
  1338.             else
  1339.                 CheckDlgButton(hDlg, IDC_LOCAL, 1) ;
  1340.             if (Windows95)
  1341.             {
  1342.                 lstrcat(szRemoteClient,"EX");
  1343.                 lstrcat(szLocalClient,"EX");
  1344.             }
  1345.             return TRUE ;
  1346.  
  1347.         case WM_COMMAND:
  1348.             switch (LOWORD(wParam))
  1349.             {
  1350.                 case IDC_CONTINUE:
  1351.                     if (IsDlgButtonChecked(hDlg, IDC_REMOTE))
  1352.                     {
  1353.                         DataLength += lstrlen(szRemote) ;
  1354.                         lstrcat(RegistryData, szRemote) ;
  1355.                     }
  1356.                     else
  1357.                     {
  1358.                         DataLength += lstrlen(szLocal) ;
  1359.                         lstrcat(RegistryData, szLocal) ;
  1360.                     }
  1361.                     ShowWindow(hDlg, SW_HIDE);
  1362.                     if (IsDlgButtonChecked(hDlg, IDC_REMOTE))
  1363.                     {
  1364.                         (void)DialogBox(hInstance,
  1365.                                         szRemoteClient,
  1366.                                         hDlg,
  1367.                                         RemoteClientDlg) ;
  1368.                     }
  1369.                     else
  1370.                     {
  1371.                         (void)DialogBox(hInstance,
  1372.                                         szLocalClient,
  1373.                                         hDlg,
  1374.                                         LocalClientDlg) ;
  1375.                     }
  1376.                     LastError = GetLastError() ;
  1377.                     if (!BackRequested) EndDialog(hDlg, 0) ;
  1378.                     return TRUE ;
  1379.  
  1380.                 case IDC_HELPT:  
  1381.                     DisplayHelp(ClientModeHelp) ;
  1382.                     return TRUE ;
  1383.  
  1384.                 case IDC_EXIT:  
  1385.                     ExitYesNoMB() ;
  1386.                     if (ExitRequested) EndDialog(hDlg, 0) ;
  1387.                     return TRUE ;
  1388.  
  1389.             }
  1390.             break ;
  1391.         }
  1392.     return FALSE ;
  1393. }
  1394.  
  1395.  
  1396.  
  1397. #ifndef ISVBUILD
  1398. /*
  1399. **      Purpose:
  1400. **              Custom Action Handler for Count Installed Apps.
  1401. **      Arguments:
  1402. **              pcd   : Ptr to class data.
  1403. **              pod   : Ptr to object data.
  1404. **              camf  : Custom action member function type.
  1405. **              pcamfd: Ptr to custom action member function data
  1406. **                      (variable size, depends on camf type).
  1407. **      Returns:
  1408. **              For all but camfInitialize, it returns rcDoDefault.  For
  1409. **              camfInitialize, it returns rcFail or rcDoDefault.
  1410. **      Notes:
  1411. **              REVIEW: Should get its message strings and definition of 'minimum'
  1412. **              from the .STF table data, but we will hardcode it here for simplicity.
  1413. **
  1414. ***************************************************************************/
  1415. RC FAR PASCAL CountInstalledApps ( PCD pcd, POD pod, CAMF camf,
  1416.                    PCAMFD pcamfd, SZ szData )
  1417. {
  1418.     Unused(pcd);
  1419.     Unused(pcamfd);
  1420.     Unused(szData);
  1421.     if (pod->ois == oisToBeInstalled)
  1422.     {
  1423.         InstalledApps++;
  1424.     }
  1425.     return (rcDoDefault);
  1426. }
  1427.  
  1428.  
  1429. /*
  1430. **      Purpose:
  1431. **              Custom Action Handler for installing ODBC.
  1432. **      Arguments:
  1433. **              pcd   : Ptr to class data.
  1434. **              pod   : Ptr to object data.
  1435. **              camf  : Custom action member function type.
  1436. **              pcamfd: Ptr to custom action member function data
  1437. **                      (variable size, depends on camf type).
  1438. **      Returns:
  1439. **              For all but camfInitialize, it returns rcDoDefault.  For
  1440. **              camfInitialize, it returns rcFail or rcDoDefault.
  1441. **      Notes:
  1442. **              REVIEW: Should get its message strings and definition of 'minimum'
  1443. **              from the .STF table data, but we will hardcode it here for simplicity.
  1444. **
  1445. ***************************************************************************/
  1446. RC FAR PASCAL InstallODBCFiles ( PCD pcd, POD pod, CAMF camf,
  1447.                    PCAMFD pcamfd, SZ szData )
  1448. {
  1449.     static char szApp1Name[50] = "ClientLicenseDialog" ;
  1450.     static BOOL ODBCFilesInstalled = FALSE ;
  1451.     HINSTANCE hLib         = NULL;
  1452.     BOOL      fStatus      = FALSE;
  1453.     CHAR      szODBCPath[300];
  1454.     CHAR      szODBCDll[300];
  1455.     CHAR      szODBCInf[300];
  1456.     CHAR      szODBCApp[300] = "StarSQL 32";
  1457.  
  1458.     Unused(pod);
  1459.     Unused(pcamfd);
  1460.     Unused(szData);
  1461.  
  1462.     if (!ODBCFilesInstalled)
  1463.     {
  1464.         switch (camf)
  1465.         {
  1466.             case camfDoNonVisualMods:
  1467.             {
  1468.                 if (((pcd->simSetupMode == simFloppyM) ||
  1469.                      (pcd->simSetupMode == simMaintM))      &&
  1470.                      (pod->ois == oisToBeInstalled))
  1471.                 {
  1472.                     lstrcpy( szODBCDll, pcd->rgchStfSrcDir );
  1473.                     lstrcat( szODBCDll, "system\\odbc\\odbccp32.dll");
  1474.                     lstrcpy( szODBCInf, pcd->rgchStfSrcDir );
  1475.                     lstrcat( szODBCInf, "system\\odbc\\ODBC.INF");
  1476.                     lstrcpy( szODBCPath, pcd->rgchStfSrcDir );
  1477.                     lstrcat( szODBCPath, "system\\odbc\\");
  1478.  
  1479.                     __try
  1480.                     {
  1481.                         fStatus = SQLInstallODBC(hDlg, 
  1482.                                      szODBCInf,
  1483.                                      szODBCPath,
  1484.                                      szODBCApp);
  1485.                         ODBCFilesInstalled = TRUE;
  1486.                     }
  1487.                     __except (EXCEPTION_EXECUTE_HANDLER)
  1488.                     {
  1489.                         ODBCFilesInstalled = FALSE;
  1490.                         return (rcDoDefault);
  1491.                     }
  1492.                 }
  1493.             }
  1494.         }
  1495.     }
  1496.     return (rcDoDefault);
  1497. }
  1498.  
  1499. #endif
  1500. /*
  1501. **      Purpose:
  1502. **              Custom Action Handler for SetClientParameters custom action.
  1503. **      Arguments:
  1504. **              pcd   : Ptr to class data.
  1505. **              pod   : Ptr to object data.
  1506. **              camf  : Custom action member function type.
  1507. **              pcamfd: Ptr to custom action member function data
  1508. **                      (variable size, depends on camf type).
  1509. **      Returns:
  1510. **              For all but camfInitialize, it returns rcDoDefault.  For
  1511. **              camfInitialize, it returns rcFail or rcDoDefault.
  1512. **      Notes:
  1513. **              REVIEW: Should get its message strings and definition of 'minimum'
  1514. **              from the .STF table data, but we will hardcode it here for simplicity.
  1515. **
  1516. ***************************************************************************/
  1517. RC FAR PASCAL SetClientParameters ( PCD pcd, POD pod, CAMF camf,
  1518.                    PCAMFD pcamfd, SZ szData )
  1519. {
  1520.     static char szApp1Name[50] = "ClientProtocols" ;
  1521.     static char szApp2Name[50] = "ClientMode" ;
  1522.     static BOOL Beenhere = FALSE ;
  1523.     static char szLicenseDlg[20] ;
  1524.     DWORD  LastError ;
  1525.     Unused(pcd);
  1526.     Unused(pod);
  1527.     Unused(pcamfd);
  1528.     Unused(szData);
  1529.  
  1530.     if( FindWindow( "SnaBase", NULL) && !ExitRequested)
  1531.     {
  1532.         if (!Beenhere) 
  1533.         {
  1534.             DisplayError(SnaBaseRunningError);
  1535.         }
  1536.         Beenhere = TRUE;
  1537.         return (rcCancel);
  1538.     }
  1539.  
  1540.  
  1541.     switch (camf)
  1542.     {
  1543.         case camfInitializeObject:
  1544.         {
  1545.                 if ((CheckForNTClient()) && (!Beenhere))
  1546.             {
  1547.                 MessageBox(GetActiveWindow(),
  1548.                            ClientInstalledText, 
  1549.                            "NT Client Installed", 
  1550.                            MB_OK|MB_ICONEXCLAMATION);
  1551.                 Beenhere = TRUE;
  1552.                 return (rcCancel) ;
  1553.             }
  1554.         }
  1555.  
  1556.         case camfAddBillBoards:
  1557.         {
  1558.             if (((pcd->simSetupMode == simFloppyM) ||
  1559.                  (pcd->simSetupMode == simMaintM))      &&
  1560.                  (pod->ois == oisToBeInstalled))
  1561.             {
  1562.                 CreateInvisibleWindow();
  1563. #ifndef ISVBUILD
  1564.                 if ((InstalledApps > 0))
  1565.                     lstrcpy(szLicenseDlg,"APPLETDLG");
  1566.                 else
  1567.                     lstrcpy(szLicenseDlg,"NOAPPLETDLG");
  1568.                 LastError = DialogBox(hInstance,
  1569.                                       szLicenseDlg,
  1570.                                       hDlg,
  1571.                                       LicenseDlg);
  1572.                 if (ExitRequested) return (rcCancel);
  1573. #endif
  1574.             }
  1575.  
  1576.             if ((pcd->simSetupMode == simFloppyM) &&
  1577.                 (pod->ois == oisToBeInstalled))
  1578.             {
  1579.                 SetupSystemParameters(pcd, pod, camf, pcamfd, szData);
  1580.                 if (Windows95)
  1581.                 {
  1582.                     lstrcat(szApp1Name,"EX");
  1583.                     lstrcat(szApp2Name,"EX");
  1584.                 }
  1585.                 LastError = DialogBox(hInstance,
  1586.                                       szApp1Name,
  1587.                                       hDlg,
  1588.                                       ClientProtocolsDlg) ;
  1589.                 LastError = GetLastError();
  1590.                 if (!ExitRequested)
  1591.                     (void)DialogBox(hInstance,
  1592.                                     szApp2Name,
  1593.                                     hDlg,
  1594.                                     ClientModeDlg) ;
  1595.                 UpdateRegistry();
  1596.                 DestroyInvisibleWindow();
  1597.             }
  1598.             break;
  1599.         }
  1600.  
  1601.         case camfFinalizeObject:
  1602.         {       
  1603.             if (pcd->simSetupMode == simMaintDeleteM)
  1604.             {
  1605.                 SetupSystemParameters(pcd, pod, camf, pcamfd, szData);
  1606.                 RemoveRegistry();
  1607.                 RemoveIniAndTraceFiles();
  1608.             }   
  1609.             break;
  1610.         }
  1611.  
  1612.         case camfPostInstall:
  1613.         {      
  1614. #ifndef ISVBUILD
  1615.  
  1616.             if (pcd->simSetupMode == simFloppyM)
  1617.             {
  1618.                 InstallSNAFontFiles();
  1619.             }
  1620. #endif
  1621.             if (pcd->simSetupMode == simMaintDeleteM)
  1622.             {
  1623.                 SetupSystemParameters(pcd, pod, camf, pcamfd, szData);
  1624.                 RemoveRegistry();
  1625.             }
  1626.             break;
  1627.         }
  1628.     }
  1629.  
  1630.     if (ExitRequested)
  1631.     { 
  1632.         RemoveRegistry() ;
  1633.         return (rcCancel) ;
  1634.     }
  1635.  
  1636.     return (rcDoDefault);
  1637. }
  1638.